import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
} //多次点击同一路由
export default new Router({
    mode: 'history',
    routes: [
        /*网站封页*/
        // {
        // 	path: '/',
        // 	name: 'gateway',
        // 	meta: {
        // 		requireAuth: true
        // 	},
        // 	component: resolve => require(['@/page/gateway'], resolve),
        // },
        // {
        //     path: '/',
        //     name: 'gateway',
        //     meta: {
        //         requireAuth: true
        //     },
        //     component: resolve => require(['@/page/newHome'], resolve),
        //     // component: resolve => require(['@/page/newGetWay'], resolve),

        //     children: [{
        //         /*网站首页*/
        //         path: '/',
        //         name: 'index',
        //         meta: {},
        //         component: resolve => require(['@/page/newGetWay'], resolve),
        //     },
        //     {
        //         /*下载app*/
        //         path: '/downLoad',
        //         name: 'downLoad',
        //         meta: {},
        //         component: resolve => require(['@/page/downLoad'], resolve),
        //     },
        //     {
        //         /*下载app*/
        //         path: '/authorWelfare',
        //         name: 'authorWelfare',
        //         meta: {},
        //         component: resolve => require(['@/page/authorWelfare'], resolve),
        //     },
        //     {
        //         /*书籍简介*/
        //         path: '/bookInfor',
        //         name: 'bookInfor',
        //         meta: {},
        //         component: resolve => require(['@/page/bookInfor'], resolve),
        //     }
        //     ]
        // },
        /* 网站主页 */
        {
            path: '/',
            name: 'home',
            redirect: {
                name: "index",
            },
            meta: {
                requireAuth: true,
                keepAlive: false
            },
            component: resolve => require(['@/page'], resolve),
            children: [
            //     {
            //     /*网站首页*/
            //     path: 'test',
            //     name: 'index',
            //     meta: {},
            //     component: resolve => require(['@/page/home/test.vue'], resolve),
            // },
            {
                /*网站首页*/
                path: 'home',
                name: 'index',
                meta: {},
                component: resolve => require(['@/page/home'], resolve),
            },
            /* 最新资讯 */
            {
                path: '/news',
                name: 'news',
                meta: {},
                component: resolve => require(['@/page/home/news'], resolve),
            },
            {
                path: '/newsDetail',
                name: 'news',
                meta: {},
                component: resolve => require(['@/page/home/news/detail.vue'], resolve),
            },
            {
                path: '/info',
                name: 'information',
                meta: {
                    requireAuth: true,
                    keepAlive: false
                },
                component: resolve => require(['@/page/home/information'], resolve),
                children: [
                    /* 帮助 */
                    {
                        path: 'help',
                        name: 'help',
                        meta: {},
                        component: resolve => require(['@/page/home/information/help.vue'], resolve),
                    }, /* 关于我们 */
                    {
                        path: 'aboutUs',
                        name: 'aboutUs',
                        meta: {},
                        component: resolve => require(['@/page/home/information/aboutUs.vue'], resolve),
                    },
                    /* 联系我们 */
                    {
                        path: 'contactUs',
                        name: 'contactUs',
                        meta: {},
                        component: resolve => require(['@/page/home/information/contactUs.vue'], resolve),
                    },
                    /* 加入我们 */
                    {
                        path: 'joinUs',
                        name: 'joinUs',
                        meta: {},
                        component: resolve => require(['@/page/home/information/joinUs.vue'], resolve),
                    },
                ]
            },

            /* 作者福利 */
            {
                path: '/authorWelfare',
                name: 'authorWelfare',
                meta: {},
                component: resolve => require(['@/page/home/authorWelfare'], resolve),
            },
            /* 站内活动 */
            {
                path: '/activity',
                name: 'activity',
                meta: {},
                component: resolve => require(['@/page/home/activity'], resolve),
            },
            /* 站内活动详情 */
            {
                path: '/activityDetail',
                name: 'activityDetail',
                meta: {},
                component: resolve => require(['@/page/home/activity/detail.vue'], resolve),
            },
            /*内容被删除*/
            {
                path: '/noValue',
                name: 'noValue',
                meta: {},
                component: resolve => require(['@/page/page/noValue.vue'], resolve),
            },
            /*403配置页*/
            {
                path: '/403',
                name: '403',
                meta: {},
                component: resolve => require(['@/page/page/403.vue'], resolve),
            },
            /*402配置页*/
            {
                path: '/402',
                name: '402',
                meta: {},
                component: resolve => require(['@/page/page/402.vue'], resolve),
            },
            /*404配置页*/
            {
                path: '/404',
                name: '404',
                meta: {},
                component: resolve => require(['@/page/page/404.vue'], resolve),
            },
            /*500配置页*/
            {
                path: '/500',
                name: '500',
                meta: {},
                component: resolve => require(['@/page/page/500.vue'], resolve),
            },
            /*完善信息*/
            {
                path: '/improveInfor',
                name: 'improveInformation',
                meta: {},
                component: resolve => require(['@/page/home/improveInformation'], resolve),
            },
            /*成功衔接页*/
            {
                path: '/success',
                name: 'success',
                meta: {},
                component: resolve => require(['@/page/home/improveInformation/success'], resolve),
            },
            {
                /*合同模板*/
                path: '/test',
                name: 'test',
                meta: {},
                component: resolve => require(['@/page/page/test'], resolve),
            },
            {
                path: '/writerTool',
                name: 'writerTool',
                meta: {},
                component: resolve => require(['@/page/writerTool'], resolve),
                children: [{
                    /*个人资料*/
                    path: '',
                    name: 'default',
                    meta: {},
                    component: resolve => require(['@/page/writerTool/writerContent.vue'], resolve),
                },]
            },
            /* 作者后台*/
            {
                path: '/author',
                name: 'author',
                meta: {
                    requireAuth: true,
                    keepAlive: false
                },
                component: resolve => require(['@/page/author'], resolve),
                children: [{
                    /*作者中心*/
                    path: 'center',
                    name: 'center',
                    meta: {},
                    component: resolve => require(['@/page/author/authorCenter'], resolve),
                    children: [{
                        /*个人资料*/
                        path: '',
                        name: 'default',
                        meta: {},
                        component: resolve => require(['@/page/author/authorCenter/userInfo'], resolve),
                    }, {
                        /*个人资料*/
                        path: 'userInfo',
                        name: 'userInfo',
                        meta: {},
                        component: resolve => require(['@/page/author/authorCenter/userInfo/show.vue'], resolve),
                        children: [{
                            path: '',
                            name: 'default',
                            meta: {},
                            component: resolve => require(['@/page/author/authorCenter/userInfo/userInfo.vue'], resolve),
                        }, {
                            path: 'realInfo',
                            name: 'realInfo',
                            meta: {},
                            component: resolve => require(['@/page/author/authorCenter/userInfo/realInfo.vue'], resolve),
                        }, {
                            path: 'changePhone',
                            name: 'changePhone',
                            meta: {},
                            component: resolve => require(['@/page/author/authorCenter/userInfo/changePhone.vue'], resolve),
                        }]
                    },
                    {
                        /*修改手机号*/
                        path: 'changePhone',
                        name: 'changePhone',
                        meta: {},
                        component: resolve => require(['@/page/author/authorCenter/userInfo/changePhone.vue'], resolve),
                    },
                    {
                        path: '/',
                        reredirect: to => 'index'
                    }
                    ]
                },

                {
                    /*作品数据*/
                    path: 'bookData',
                    name: 'bookData',
                    meta: {},
                    component: resolve => require(['@/page/author/bookData'], resolve),
                },
                {
                    /*作者数据*/
                    path: 'workData',
                    name: 'workData',
                    meta: {},
                    component: resolve => require(['@/page/author/workData'], resolve),
                },
                {
                    /*稿酬收入*/
                    path: 'contriIncome',
                    name: 'contributionIncome',
                    meta: {},
                    component: resolve => require(['@/page/author/contributionIncome'], resolve),
                    children: [{
                        /*打赏明细*/
                        path: 'rewardDetails',
                        name: 'rewardDetails',
                        meta: {},
                        component: resolve => require(['@/page/author/contributionIncome/rewardDetails.vue'], resolve),
                    }, {
                        /*税务明细*/
                        path: 'taxDetails',
                        name: 'taxDetails',
                        meta: {},
                        component: resolve => require(['@/page/author/contributionIncome/taxDetails.vue'], resolve),
                    }, {
                        path: 'allshow',
                        name: 'allshow',
                        meta: {},
                        component: resolve => require(['@/page/author/contributionIncome/allShow.vue'], resolve),
                    }, {
                        path: '',
                        redirect: to => 'allshow'
                    }]
                },
                {
                    /*作家咨询*/
                    path: 'msgCenter',
                    name: 'messageCenter',
                    meta: {},
                    component: resolve => require(['@/page/author/messageCenter'], resolve),
                    children: []
                },
                {
                    /*评论管理*/
                    path: 'commentManage',
                    name: 'commentManagement',
                    meta: {},
                    component: resolve => require(['@/page/author/commentManagement'], resolve),
                    children: []
                },
                {
                    /*作品管理*/
                    path: 'bookManage',
                    name: 'bookManagement',
                    meta: {},
                    component: resolve => require(['@/page/author/bookManagement'], resolve),
                    children: [{
                        path: '',
                        name: 'default',
                        meta: {},
                        component: resolve => require(['@/page/author/bookManagement/default.vue'],
                            resolve),
                    }, {
                        path: 'applymanage',
                        name: 'applyMenagement',
                        meta: {},
                        component: resolve => require(['@/page/author/bookManagement/applyMenagement.vue'],
                            resolve),
                    },
                    {
                        path: 'bookSetting',
                        name: 'bookSetting',
                        meta: {},
                        component: resolve => require(['@/page/author/bookManagement/bookSetting.vue'], resolve),
                    }, {
                        path: 'createBook',
                        name: 'createBook',
                        meta: {},
                        component: resolve => require(['@/page/author/bookManagement/createBook.vue'], resolve),

                    },

                    ]
                },
                {
                    /*合同模板*/
                    path: 'contractTep',
                    name: 'contractTemplate',
                    meta: {},
                    component: resolve => require(['@/page/author/contractTemplate'], resolve),
                },
                ]
            },
            ]
        },
        {
            /*H5分享页面*/
            path: '/h5page',
            name: 'h5page',
            meta: {},
            component: resolve => require(['@/page/author/h5page'], resolve),
        },
        {
            path: '/*',
            redirect: to => '/404'
        }
    ]
})